package com.xcity.game.battle.pve.employee.impl;

import com.xcity.game.battle.pve.PlayerBattler;
import com.xcity.game.battle.pve.employee.EmployeeSkillBattleContext;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.employee.skill.EmployeeSkill;

public class RECOVER_HP_AFTER_BE_ATTACKED_CONTEXT extends EmployeeSkillBattleContext {

	public RECOVER_HP_AFTER_BE_ATTACKED_CONTEXT(PlayerBattler player, EmployeeSkill ref) {
		super(player, ref);
	}

	@Override
	public boolean trigger() {
		if (player.getHp() <= 0) {
			return false;
		}
		int n = rnd.nextInt(GameStaticConfig.percentBase);
		if (n < ref.getTemplate().getInitVal(0)) {
			int added = (int) (player.getContext().getTarget().getAttack() * ref.getTemplate().getInitVal(1) / 100);
			player.setHp(player.getHp() + added);
			return true;
		}
		return false;
	}

}
